<extend name="Base/common" />

<block name="style">
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/Api/css/order.css">
</block>

<block name="Content">

<div class="page-group">
    <div class="page page-current my-order">
    	
    	<switch name="orderModel.status">
    		<case value="1">
               	<div class="bar bar-standard bar-footer order-foot">
		            <div class="content-block order-foot-block button-two">
		                <div class="row">
		                    <div class="col-50">
		                    	<a href="#" onclick="cancel('{$orderModel['order_id']}')" 
		                    		class="button button-big button-fill button-apply">申请退单</a>
		                    </div>
		                    <div class="col-50">
		                    	<a href="tel:4008526519" class="button button-big button-fill button-contact">联系客服</a>
		                    </div>
		                </div>
		            </div>
		        </div>
            </case>
    		<case value="2">
               	<div class="bar bar-standard bar-footer order-foot">
		            <div class="content-block order-foot-block button-two">
		                <div class="row">
		                    <div class="col-50">
		                    	<a href="tel:{$workerModel['account']|default='4008526519'}" 
		                    		class="button button-big button-fill button-apply">申请退单</a>
		                    </div>
		                    <div class="col-50">
		                    	<a href="tel:4008526519" class="button button-big button-fill button-contact">联系客服</a>
		                    </div>
		                </div>
		            </div>
		        </div>
            </case>
    		<case value="3">
               	<div class="bar bar-standard bar-footer order-foot">
		            <div class="content-block order-foot-block button-two">
		                <div class="row">
		                    <div class="col-50"><a href="#" class="button button-big button-fill disabled">申请退单</a></div>
		                    <div class="col-50"><a href="tel:4008526519" class="button button-big button-fill button-contact">联系客服</a></div>
		                </div>
		            </div>
		        </div>
            </case>
    		<case value="4">
               	<div class="order-foot bar bar-standard bar-footer">
		            <div class="content-block order-foot-block">
		                <div class="row">
		                    <div class="col-100">
		                    	<a href="{:U('WeChatApi/jsApiCall', 'order_id='.$orderModel['order_id'])}" data-no-cache="true"
		                    			class="button button-big button-fill button-pay">支付</a>
		                    </div>
		                </div>
		            </div>
		        </div>
            </case>
    	</switch>
        
        <div class="content">
        	<empty name="workerModel">
	            <div class="top">
	                <div class="container">暂无接单</div>
	            </div>
	        <else/>
	        	<div class="order-detail-top" 
	        		onclick="javascript:window.location.href='{:U('Worker/viewAction', 'worker_id='.$workerModel['worker_id'])}'">
	                <div class="list-block media-list">
	                    <ul>
	                        <li class="order-p">
	                            <div class="item-content">
	                                <div class="item-media">
	                                    <img src="{$workerModel['fullpath']|default='__PUBLIC__/Api/images/person1.png'}" alt="">
	                                </div>
	                                <div class="item-inner">
	                                    <div class="item-title-row">
	                                        <div class="item-title">{$workerModel['name']} {$workerModel['account']}
	                                        	<span class="order-num">{$workerModel['orders_sum']} 单</span>
	                                        </div>
	                                    </div>
	                                    <div class="item-subtitle">
	                                    	<for start="0" end="5">
                                      	    	<if condition="$workerModel['score']/2 gt $i">
                                      	    		<img src="__PUBLIC__/Api/images/taoxin.png">
                                      	    	</if>
										    </for>
	                                    </div>
	                                    <div class="item-subtitle">工号：{$workerModel['eid']}</div>
	                                </div>
	                            </div>
	                        </li>
	                    </ul>
	                </div>
	            </div>
	        </empty>
            <div class="order-details">
                <p class="order-title">订单详情</p>
                <ul class="order-details-list">
                    <li><span>订单编号：</span><span>{$orderModel['order_no']}</span></li>
                    <li><span>下单时间：</span><span>{$orderModel['create_time']|GetDateTimeMk}</span></li>
                    <li><span>检测部位：</span><span>{$orderModel['detail_name']}</span></li>
                    <li>
                    	<span>预约时间：</span>
                    	<span>
                    		<if condition="$orderModel.emergency eq '2'">
                    			{$orderModel['delay']|default='50'}分钟
                    		<else/>
                    			{$orderModel['appointment']|GetDateTimeMk}
                    		</if>
                    	</span>
                    </li>
                    <li>
                    	<span class="contacts">联系人：</span><span>{$orderModel['contact']}</span>
                    </li>
                    <li><span>联系电话：</span><span>{$orderModel['telphone']}</span></li>
                    <li><span>地　　址：</span><span>{$orderModel['address']}{$orderModel['name']}</span></li>
                    <li class="clearfix remark">
                        <span class="left">备　　注：</span>
                        <span class="left">{$orderModel['remark']}</span>
                    </li>
                </ul>
            </div>
            <div class="order-details">
            	<p class="order-title">维修部位图片</p>
            	<div class="server-list clearfix">
                <ul class="order-details-list">
                	<notempty name="list">
                		<foreach name="list" item="record">
                			<li>
		                        <img src="{$record}"/>
		                    </li>
                		</foreach>
                	</notempty>
                </ul>
                </div>
            </div>
        </div>
    </div>
</div>

</block>

<block name="script">
<script type="text/javascript">

function cancel(orderID){
	
	if(!isNaN(orderID)){
		
		$.prompt('退单申请说明', function (value) {
			
			var target = Think.U('Orders/cancel');
			$.post(target, {'order_id':orderID, 'reason':value}, function(data){
				if(data.status == '0'){
					$.confirm('参数错误，请刷新后重试', function () {
				    	window.location.reload();
			      	});
				}else if(data.status == '-201'){
					$.confirm('身份认证已失效，请重新登录', function () {
				        var loginURL = Think.U('Public/login');
				        window.location.href = loginURL;
				        return false;
				    });
				}else if(data.status == '1'){
					$.toast('您已退单成功', 1000);
					window.location.href = Think.U('Orders/index');
				}
			});
		});
	}
}

</script>
</block>

